import axios from 'axios';

export function uniGet(action: string, params: any) {
  return axios.get(action, { params });
}

export function uniPost(action: string, data: any) {
  return axios.post(action, data);
}

export function uniRequest(api: string, method: string, data: any) {
  const config = {
    url: api,
    method,
  };
  if (method.toLowerCase().includes('post')) {
    config['data'] = data;
  } else {
    config['params'] = { ...data };
  }
  return axios.request(config);
}